package com.roncoo.student.stu.service.impl;

import com.roncoo.student.stu.dao.WebStudentsMapper;
import com.roncoo.student.stu.entity.WebStudents;
import com.roncoo.student.stu.service.IWebStudentsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jl
 * @since 2021-03-22
 */
@Service
public class WebStudentsServiceImpl extends ServiceImpl<WebStudentsMapper, WebStudents> implements IWebStudentsService {



    @Resource
    private WebStudentsMapper webStudentsMapper;

    
    @Override
    public IPage<Map> findAll(WebStudents webStudents, Page page) {

        page.setSize(4);
        QueryWrapper<WebStudents> wrapper = new QueryWrapper<>();


        if (StringUtils.isNotBlank(webStudents.getUsername())){
            wrapper.like("username",webStudents.getUsername());
        }
        if (StringUtils.isNotBlank(webStudents.getNickname())){
            wrapper.like("nickname",webStudents.getNickname());
        }
        if (webStudents.getStatus()!=null){
            wrapper.eq("status",webStudents.getStatus());
        }
        Page page1 = webStudentsMapper.selectPage(page, wrapper);

        return page1;
    }
}
